<extend name="Layout/ins_page" />
   
<block name="content">
{:W('PageHeader/adv_search',array('name'=>'我的通知清单','search'=>'M'))}

 <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
<form method="post" name="form_adv_search" id="form_adv_search">

	<div class="adv_search panel panel-default hidden" id="adv_search">
	
		<div class="panel-heading">
			<div class="row">
				<h4 class="col-xs-6">高级搜索</h4>
				<div class="col-xs-6 text-right">
					<a  class="btn btn-sm btn-info" onclick="submit_adv_search();">搜索</a>
					<a  class="btn btn-sm" onclick="close_adv_search();">关闭</a>
				</div>
			</div>
		</div>
		<div class="panel-body">
		

			
		</div>
	</div>
</form>
<div class="ul_table ul_table_responsive" style="font-size:14px" >
	<ul>
		<li class="thead" style="padding-left:10px">
			<div class="pull-left">
				<span class="col-13 ">ID</span>
				<span class="col-16 ">名称</span>
				<span class="col-22 ">平台</span>	
				<span class="col-15 ">通知对象</span>	
				<span class="col-15 ">时间</span>	
				<span class="col-15 ">操作</span>	
				
							
			</div>
			<div class="pull-right">
			</div>
			
			<div class="autocut auto">
			
		</li>
	</ul>
	<empty name="list">
		<ul>
			<li class="no-data">
				没找到数据
			</li>
		</ul>
		<else/>
		<form method="post" action="" name="form_data" id="form_data">
			<ul>
				
				<?php foreach($list as $vo){
				
				?>
					<li class="tbody ">
						<div class="pull-left">
							<span class="col-13 "><?php echo $vo['id']?>&nbsp;</span>
							<span class="col-15 "><?php echo $vo['name']?>&nbsp;</span>
							<span class="col-22 "><?php echo $vo['u_name']?>&nbsp;</span>
							<span class="col-15 "><?php echo $vo['to_emp']?>&nbsp;</span>
							<span class="col-16 "><?php echo date('Y-m-d H:i:s',$vo['ctime'])?></span>
							<span class="col-15 ">
							<a href="/Shelves/shelvesNoticeMs?id=<?php echo $vo['id']?>"  >详情</a>
							<a href="javascript:void(0)"  onclick="change('<?php echo $vo['id']?>')" data-id="<?php echo $vo['id']?>" class='mx'>预览</a>
						     <a onclick="send('<?php echo $vo['id']?>')"  >发送通知</a></span>

						</div>
						<div class="pull-right">
							
							
						</div>
						<div class="autocut auto">
						
							 </div>
					</li>
				<?php } ?>
			</ul>
		</form>
		<div class="pagination">
			{$page}
		</div>
	</empty>
	<a  class="btn btn-sm btn-primary" data-toggle="modal" data-target="#myModal" onclick="showauth()">清单授权</a>
</div>

    <div style="right:20px; top:88px; position:absolute;display: none;z-index: 99999;background-color: #ffffff;box-shadow: -2px 10px 10px  #888888;-moz-box-shadow: -2px 10px 10px #888888;" id='qdan-show'>
                <div id="grid2" class="mini-datagrid" style="width:600px;height:500px;border: 1px solid gray"                     
                    idField="id"  multiSelect="true" showPager="false"
                    allowCellEdit="true" allowCellSelect="true" 
                >
                    <div property="columns">
                        <div type="checkcolumn"></div>
                         <div header="物料编号" field="code" width="80px"></div>
                         <div header="物料名称" field="name"  width="200px"></div>
                            
                        </div>
                    </div>
                   &nbsp; <input type="button" value="移除所选物料" onclick="removes()" style="width:100px;"/> &nbsp;&nbsp;<a  href='javascript:void(0)' class='close_show' >关闭</a>
    </div>
    
    
    <!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">清单授权</h4>
      </div>
      <div class="modal-body">
   		<p>请输入授权用户,多个用户,号分隔;授权用户可以操作清单数据</p>
   		<input id="textarea1" name="Area" class="mini-textarea" required="true" width="100%"/>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" onclick="saveauth()">保存</button>
      </div>
    </div>
  </div>
</div>


<script type="text/javascript">

    jQuery('.close_show').click(function(){
    	 jQuery('#qdan-show').hide();
    })

        mini.parse();
        var grid2 = mini.get("grid2");

        function removes() {
            var items = grid2.getSelecteds();
            var ids = '';
           	for(var index =0;index<items.length;index++){
           		ids+=items[index].id+",";
           	}
           	
            $.ajax({
                url: "/Shelves/delShelvesDetailed",
                type: "post",
                data: {ids:ids },
                dataType:'json',
                success: function (data) {
                }
            });
            grid2.removeRows(items);
          //  grid1.addRows(items);
        }
      
        function change(id){
        	if(id==''){
        		return ;
        	}
        	
            $.ajax({
                 url: "/Shelves/getShelvesDetailed",
                 type: "post",
                 data: { pid: id },
                 dataType:'json',
                 success: function (data) {
                	 grid2.setData(data);
                	 jQuery('#qdan-show').show();
                 }
             });
        }
        
        function send(id){
        	loadingmsg('发送中....');
            $.ajax({
                url: "/Shelves/sendnotice",
                type: "post",
                data: { id:id },
                dataType:'json',
                success: function (data) {
                	  mini.unmask(document.body);
                   	  mini.alert(data.msg)
                }
            });
        }
        
        function showauth(){
        	 loadingmsg('加载授权用户....');
        	  $.ajax({
                  url: "/Shelves/getauthList",
                  type: "post",
                  dataType:'text',
                  success: function (data) {
                	  mini.get('textarea1').setValue(data);
                	  colseloading();
                  }
              });
        }
        
     function saveauth(){
    	 loadingmsg('保存中....');
    	 var users = mini.get('textarea1').getValue();
    	   $.ajax({
               url: "/Shelves/saveauth",
               type: "post",
               data: { users:users},
               dataType:'json',
               success: function (data) {
            	   $('#myModal').modal('toggle');
            	   colseloading();
               	 if(data>0)
                   mini.alert('保存成功');
                  
               }
           });
    	 
     }
        
    </script>
</block>

  

